package cn.cvs.convert;

import org.springframework.core.convert.converter.Converter;

import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;

public class StringToDateConvert implements Converter<String,Date> {

    public String getPattern() {
        return pattern;
    }

    public void setPattern(String pattern) {
        this.pattern = pattern;
    }

    private String pattern;

    @Override
    public Date convert(String s) {
        SimpleDateFormat format=new SimpleDateFormat(pattern);
        Date date=null;
        try{
            date=format.parse(s);
        }catch (ParseException e){
            e.printStackTrace();
        }
        return date;
    }
}
